package model

import (
	"fmt"
	"time"
)


func InsertAnswer(id,data,result string)bool{
	//result:=1


	stmt, err := DB.Prepare("Insert into answer(student_id,student_answer,result,create_time) values($1,$2,$3,$4)")
	if err != nil {
		fmt.Println("Some amazing wrong happens in preparation for the insert.")
		return false
	}
	defer stmt.Close()

	res, err := stmt.Exec(id,data,result,time.Now().Unix())
	if err != nil {
		fmt.Println("Some amazing wrong happens in the process of doInsertOne.")
		return false
	}
	num, err := res.RowsAffected()
	if err != nil {
		fmt.Println("Some amazing wrong happens in the affected fo deletion.")
		return false
	}
	fmt.Println("Successfully add ", num)
	return true


}
